﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FasterThanLightEngine
{
    public class Direction
    {
        public double Pitch
        {
            get;
            protected set;
        }

        public double Yaw
        {
            get;
            protected set;
        }

        public Direction()
        { }

        public Direction(double pitch, double yaw)
        {
            // Take out-of-bounds values and put them into bounds.
            while (pitch > 270)
            {
                pitch -= 360;
            }

            while (pitch < -270)
            {
                pitch += 360;
            }

            if (pitch > 90)
            {
                pitch = 180 - pitch;
            }

            if (pitch < -90)
            {
                pitch = -180 - pitch;
            }

            while (yaw >= 360)
            {
                yaw -= 360;
            }

            while (yaw < 0)
            {
                yaw += 360;
            }

            this.Pitch = pitch;
            this.Yaw = yaw;
        }

        public Direction(Direction other)
        {
            this.Pitch = other.Pitch;
            this.Yaw = other.Yaw;
        }
    }
}
